const Controller = require('../core/base_controller');

class HomeController extends Controller {
    async getBlog() {
        const { ctx, app } = this;
        // controller值负责收和发
        // 复杂业务逻辑处理 交给了 Service
        try {
            const res = await this.ctx.service.blog.getBlog()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }

    }
    async addBlog() {
        const { ctx, app } = this;
        // controller值负责收和发
        // 复杂业务逻辑处理 交给了 Service
        try {
            const res = await this.ctx.service.blog.addBlog()
            this.success(res)
        } catch (err) {
            this.error(err.message)

        }

    }
    async editBlog() {
        const { ctx, app } = this;
        // controller值负责收和发
        // 复杂业务逻辑处理 交给了 Service
        try {
            const res = await this.ctx.service.blog.editBlog()
            this.success(res)

        } catch (err) {
            this.error(err.message)

        }
    }
    async delBlog() {
        const { ctx, app } = this;
        // controller值负责收和发
        // 复杂业务逻辑处理 交给了 Service
        try {
            const res = await this.ctx.service.blog.delBlog()
            this.success(res)

        } catch (err) {
            this.error(err.message)

        }
    }
}

module.exports = HomeController;
